package net.taiqin.tqerp.controller.param.common;

import com.github.pagehelper.IPage;
import net.taiqin.tqerp.common.GlobalConstants;

public class PageParam implements IPage {
    private Integer pageNum;
    private Integer pageSize;
    private String orderBy;

    public void setPageNum(Integer pageNum) {
        this.pageNum = pageNum;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public void setOrderBy(String orderBy) {
        this.orderBy = orderBy;
    }

    public Integer getPageNum() {
        if (this.pageNum == null) {
            this.pageNum = GlobalConstants.DEFAULT_PAGE_NUM;
        } else if (this.pageNum == -1 || this.pageNum > GlobalConstants.MAX_PAGE_NUM) {
            this.pageNum = GlobalConstants.MAX_PAGE_NUM;
        }

        return this.pageNum;
    }

    public Integer getPageSize() {
        if (this.pageSize == null) {
            this.pageSize = GlobalConstants.DEFAULT_PAGE_SIZE;
        } else if (this.pageSize == -1 || this.pageSize > GlobalConstants.MAX_PAGE_SIZE) {
            this.pageNum = GlobalConstants.MAX_PAGE_SIZE;
        }

        return this.pageSize;
    }

    public String getOrderBy() {
        return this.orderBy;
    }
}
